package com.rw.admin.controller;

import com.github.pagehelper.PageInfo;
import com.rw.common.pojo.CarInfo;
import com.rw.admin.service.CarInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author rabit
 */
@RestController
@RequestMapping("carInfo")
public class CarInfoController {
    @Autowired
    private CarInfoService carInfoService;

    @RequestMapping("list")
    public Map<String, Object> getCarInfoList(@RequestParam("page") Integer pageNum,@RequestParam("limit") Integer limit){
        Map<String, Object> map =new HashMap<>();

        if (pageNum== null || pageNum < 1){
            pageNum = 1;
        }
        if (limit== null ||limit < 1){
            limit = 15;
        }
        PageInfo page = carInfoService.getDataByPage(pageNum, limit);
        map.put("code",0);
        map.put("msg","");
        map.put("count",page.getTotal());
        map.put("data",page.getList());
        return map;
    }
}
